#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
    resize(300,150);
    lb1=new QLabel(this);
    lb2=new QLabel(this);
    lb3=new QLabel(this);
    lb4=new QLabel(this);
    lb5=new QLabel(this);

    lb11=new QLabel(this);
    lb22=new QLabel(this);
    lb33=new QLabel(this);
    lb44=new QLabel(this);
    lb55=new QLabel(this);

    lb1->setText("函数geomery():");
    lb2->setText("函数width():");
    lb3->setText("函数height():");
    lb4->setText("函数rect():");
    lb5->setText("函数size():");

    layout=new QGridLayout(this);
    layout->addWidget(lb1,0,0);
    layout->addWidget(lb2,1,0);
    layout->addWidget(lb3,2,0);
    layout->addWidget(lb4,3,0);
    layout->addWidget(lb5,4,0);

    layout->addWidget(lb11,0,1);
    layout->addWidget(lb22,1,1);
    layout->addWidget(lb33,2,1);
    layout->addWidget(lb44,3,1);
    layout->addWidget(lb55,4,1);

    showInformation();

}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::resizeEvent(QResizeEvent *)
{
        showInformation();
}

void Dialog::moveEvent(QMoveEvent *event)
{
     showInformation();
}

void Dialog::showInformation()
{
    QString strr;//用来存放geometry()函数的显示结果
    QString str1,str2,str3,str4;

    strr=str1.setNum(geometry().x())+","+str2.setNum(geometry().y())+","+str3.setNum(geometry().width())+","+str4.setNum(geometry().height());
    lb11->setText(strr);

    lb22->setText(str3.setNum(geometry().width()));

    lb33->setText(str4.setNum(geometry().height()));

    strr=str1.setNum(rect().x())+","+str2.setNum(rect().y())+","+str3.setNum(rect().width())+","+str4.setNum(rect().height());

    lb44->setText(strr);

    lb55->setText(str3.setNum(rect().width())+","+str4.setNum(rect().height()));



}

